package easy;

public class Solution_1539 {

    public int findKthPositive(int[] arr, int k) {
        int val = 0;
        for (int num : arr) {
            int sub = num - val - 1;
            if (sub >= k) {
                return val + k;
            } else {
                k -= sub;
            }
            val = num;
        }
        return val + k;
    }

    public static void main(String[] args) {
        Solution_1539 model = new Solution_1539();
        System.out.println(model.findKthPositive(new int[]{2, 3, 4, 7, 11}, 5));
        System.out.println(model.findKthPositive(new int[]{1, 2, 3, 4}, 2));
    }
}
